package com.woniuxy.controller;

import com.woniuxy.entity.Book;
import com.woniuxy.service.BookService;
import com.woniuxy.util.ResponseData;
import jdk.nashorn.internal.objects.annotations.Getter;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.annotation.Resource;
import java.util.Iterator;
import java.util.List;

/**
 * @author dingpf
 * @version 1.0
 * @description
 * @create 2025/4/21 16:54
 */
@RestController
@RequestMapping("/book")
//@CrossOrigin(origins = "*") //此类的方法允许跨域访问，跨域默认不能访问的。
public class BookController {

    @Resource
    private BookService bookService;

    @GetMapping("/queryAll")
    private ResponseData queryAll(){
        List<Book> books = bookService.queryAll();
        return ResponseData.ok(books);
    }

    @GetMapping("/queryDetail/{id}")
    public ResponseData queryDetail(@PathVariable("id") Integer id){
        Book book = bookService.queryBookById(id);
        return ResponseData.ok(book);
    }
}
